﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using IntroduceCompany.Singleton;
using IntroduceCompany.Util;

namespace IntroduceCompany.Models
{
    public class CompanyMemberModels
    {


        /// <summary>
        /// Get all company member filter by languageID
        /// </summary>
        /// <param name="languageID"></param>
        /// <returns></returns>
        internal IQueryable<CompanyMemberView> GetCompanyMemberList(String languageID)
        {
            if (languageID == ConstantClass.markViewAllLanguage)
            {
                return DataSingleton.GetInstance().CompanyMemberViews.OrderByDescending(mem => mem.MemberID);
            }
            else
            {
                return DataSingleton.GetInstance().CompanyMemberViews.Where(mem => mem.LanguageID == languageID).OrderByDescending(mem => mem.MemberID);
            }
        }


        /// <summary>
        /// Get a member filter by memberID and languageID
        /// </summary>
        /// <param name="memberID"></param>
        /// <param name="memberLanguageID"></param>
        /// <returns></returns>
        internal CompanyMemberView GetOneMember(int memberID, string memberLanguageID)
        {
            return DataSingleton.GetInstance().CompanyMemberViews.SingleOrDefault(mem => mem.MemberID == memberID && mem.LanguageID == memberLanguageID);
        }
    }
}